package com.xinsoft.entity.dto;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.xinsoft.constant.Const;
import com.xinsoft.entity.vo.ErpPurchaseNoticeVO;
import com.xinsoft.entity.vo.ErpPurchaseVO;
import com.xinsoft.utils.RedisUtil;
import lombok.Data;

import javax.annotation.Resource;

/**
 * 采购订单
 * */
@Data
public class KisPurchaseHeadDto {

    private String FInterID;         //id
    private String FBillNo;         //编    号
    private String FSupplyID;         //350,
    private String FDate;         //9/11/2023 12:00:00 AM,	交货日期
    private String FEmpID;         //8505,				业务员
    private String FDeptID;         //4072,				部门
    private String FCheckerID;         //16393,			审核
    private String FBillerID;         //16404,			制单
    private String FMangerID;         //0,				主管
    private String FCheckDate;         //9/15/2023 12:00:00 AM,	审核日期
    private String FSettleDate;         // 9/11/2023 12:00:00 AM,	结算日期
    private String FChangeDate;         //				变更日期
    private String FChangeCauses;         //			变更原因
    private String FReceiveAddr;         //				收货地址
    private String FArriveDate;         //9/11/2023 12:00:00 AM,  送货日期
    private String FSupplyLink;         //侯海兵/吴新,    联系人
    private String FValidDate;         //30,				有效天数
    private String FValidFlag;         //1,				有效期标志


    private RedisUtil redisUtil = SpringUtil.getBean(RedisUtil.class);
    
    public ErpPurchaseVO voToPo(KisPurchaseHeadDto item) {
        if (item == null) {
            return null;
        }
        ErpPurchaseVO erpPurchaseVO = new ErpPurchaseVO();
        erpPurchaseVO.setId(ObjectUtil.isEmpty(item.getFInterID()) ? null : new Integer(item.getFInterID()));
        erpPurchaseVO.setCode(item.getFBillNo());
        erpPurchaseVO.setSupplyId(ObjectUtil.isEmpty(item.getFSupplyID()) ? null : new Integer(item.getFSupplyID()));
        erpPurchaseVO.setDate((ObjectUtil.isEmpty(item.getFDate()) ? null : DateUtil.formatDate(DateUtil.parse(item.getFDate(),redisUtil.get(Const.TIME_FORMAT).toString()))) );
        erpPurchaseVO.setEmpId(ObjectUtil.isEmpty(item.getFEmpID()) ? null : new Integer(item.getFEmpID()));
        erpPurchaseVO.setDeptID(ObjectUtil.isEmpty(item.getFDeptID()) ? null : new Integer(item.getFDeptID()));
        erpPurchaseVO.setCheckerId(ObjectUtil.isEmpty(item.getFCheckerID()) ? null : new Integer(item.getFCheckerID()));
        erpPurchaseVO.setBillerId(ObjectUtil.isEmpty(item.getFBillerID()) ? null : new Integer(item.getFBillerID()));
        erpPurchaseVO.setMangerId(ObjectUtil.isEmpty(item.getFMangerID()) ? null : new Integer(item.getFMangerID()));
        erpPurchaseVO.setCheckDate((ObjectUtil.isEmpty(item.getFCheckDate()) ? null : DateUtil.formatDate(DateUtil.parse(item.getFCheckDate(),redisUtil.get(Const.TIME_FORMAT).toString()))));
        erpPurchaseVO.setSettleDate((ObjectUtil.isEmpty(item.getFSettleDate()) ? null : DateUtil.formatDate(DateUtil.parse(item.getFSettleDate(),redisUtil.get(Const.TIME_FORMAT).toString()))) );
        erpPurchaseVO.setChangeDate((ObjectUtil.isEmpty(item.getFChangeDate()) ? null : DateUtil.formatDate(DateUtil.parse(item.getFChangeDate(),redisUtil.get(Const.TIME_FORMAT).toString()))) );
        erpPurchaseVO.setChangeCauses(item.getFChangeCauses());
        erpPurchaseVO.setReceiveAddr(item.getFReceiveAddr());
        erpPurchaseVO.setArriveDate((ObjectUtil.isEmpty(item.getFArriveDate()) ? null : DateUtil.formatDate(DateUtil.parse(item.getFArriveDate(),redisUtil.get(Const.TIME_FORMAT).toString()))) );
        erpPurchaseVO.setSupplyLink(item.getFSupplyLink());
        erpPurchaseVO.setValidDate((ObjectUtil.isEmpty(item.getFValidDate()) ? null : item.getFValidDate()));
        erpPurchaseVO.setValidFlag(item.getFValidFlag());
        return erpPurchaseVO;
    }

//    {
//        FInterID: 20460,
//        FBillNo: PO2023091107, 		编    号
//        FSupplyID: 350,
//        FDate: 9/11/2023 12:00:00 AM,	交货日期
//        FEmpID: 8505,				业务员
//        FDeptID: 4072,				部门
//        FCheckerID: 16393,			审核
//        FBillerID: 16404,			制单
//        FMangerID: 0,				主管
//        FCheckDate: 9/15/2023 12:00:00 AM,	审核日期
//        FExplanation: ,				摘要
//        FSettleDate: 9/11/2023 12:00:00 AM,	结算日期
//        FSettleID: 2,				结算方式
//        FSelTranType: 70,			源单类型
//        FChangeDate: ,				变更日期
//        FChangeCauses: ,			变更原因
//        FReceiveAddr: ,				收货地址
//        FArriveDate: 9/11/2023 12:00:00 AM,  送货日期
//        FSrcBrID: 0,	             申请机构
//        FSupplyLink: 侯海兵/吴新,    联系人
//        FValidDate: 30,				有效天数
//        FValidFlag: 1,				有效期标志
//        FBrNo: 0,
//        FTranType: 71,
//        FCurrencyID: 1,
//        FClosed: 0,
//        FTranStatus: 0,
//        FExchangeRate: 1,
//        FStatus: 1,
//        FCancellation: False,
//        FPOStyle: 252,             采购方式
//        FMultiCheckLevel1: ,
//        FMultiCheckLevel2: ,
//        FMultiCheckLevel3: ,
//        FMultiCheckLevel4: ,
//        FMultiCheckLevel5: ,
//        FMultiCheckLevel6: ,
//        FMultiCheckDate1: ,
//        FMultiCheckDate2: ,
//        FMultiCheckDate3: ,
//        FMultiCheckDate4: ,
//        FMultiCheckDate5: ,
//        FMultiCheckDate6: ,
//        FCurCheckLevel: ,
//        FRelateBrID: 0,				供货机构
//        FOrderAffirm: 0,
//        FCashDiscount: ,
//        FFetchAdd: ,
//        FChildren: 0,
//        FBrID: 0,
//        FPOOrdBillNo: ,
//        FAreaPS: 20302,				采购范围
//        FClassTypeID: 0,
//        FTotalCostFor: 0.0000,
//        FlastModyDate: ,
//        FOperDate: System.Byte[],
//        FManageType: 0,
//        FSysStatus: 2,
//        FVersionNo: 000,
//        FChangeMark: 0,
//        FChangeUser: 0,
//        FValidaterName: ,
//        FConsignee: 0,
//        FPrintCount: 0,
//        FTplStatus: ,
//        FTplFail: ,
//        FTplflat: ,
//        FTplStock: ,
//        FTplIsPutIn: ,
//        FStockID: 0,
//        FOrderType: 36720,
//        FSettCycle: 0,
//        FSupplyTel: 0523-84601234,
//        FAmountExclTax: 0.0000000000,
//        FAmountInclTax: 0.0000000000,
//        FTplQueryStatus: 0,
//        FTplOrderID: ,
//        FHeadSelfP0260: ,
//        FMultiCheckStatus: 16
//    }
}
